1 Intro

To show you what you can do with markdown files, I will try to reproduce the figure posted by the Federal Office of Public Health on COVID-19 cases in Switzerland. Their website is at https://covid-19-schweiz.bagapps.ch/de-2.html.

Here is a screen shot of their website app.

knitr::include_graphics("Dashboard.png")

2 Format the data set

Some cantons don’t update their cases daily. Therefore a lot of NA entries were made.

I fixed this by filling the in between entries with the nearest next entry and the NA rows before the onset of the virus with 0.

#load data
df <- read.csv("covid_19_data_switzerland.csv")
df[1:10,]
#Fill missing data
df <- df %>% fill(AG:CH, .direction = c("down"))
df[is.na(df)] <- 0
df

3 Plots

We can plot interactive plots with plotly.

fig <- plot_ly(type = "scatter", mode = "lines")

for (i in 2:ncol(df)) {
fig <- add_trace(fig, x = df[,1],
          y = df[,i],
          data = df,
          name = colnames(df)[i],
          type = 'scatter',
          mode = 'lines')
}
fig